Imports System.Net.Mail
Partial Class email
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        If Not Page.IsPostBack Then
            sendMail("ngminhy1@yahoo.com", "abv", "asdfas")
        End If
    End Sub
    Private Function sendMail(ByVal vAddress As String, ByVal vSubject As String, ByVal vContent As String) As Boolean
        Dim mailmsg As New MailMessage
        mailmsg.Priority = MailPriority.Normal
        mailmsg.IsBodyHtml = True
        mailmsg.From = New MailAddress("kdadmin@hcm.vnn.vn")
        mailmsg.To.Add(vAddress)
        mailmsg.Subject = vSubject
        mailmsg.Body = vContent

        Dim objMail As New SmtpClient("smtp.hcm.vnn.vn")

        Try
            objMail.Send(mailmsg)
        Catch ex As Exception
            Response.Write(ex.ToString)
        Finally
            Response.Write("An email has been sent")
        End Try
    End Function
End Class
